package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.activity.ClassifyGoodsListActivity;
import com.weixin.paleituo.base.ComAdapter;
import com.weixin.paleituo.bean.ChildrenBean;
import com.weixin.paleituo.help.ViewHolder;
import com.weixin.paleituo.util.UIUtils;

import java.util.List;

/**
 * Author yichao
 * Time  2018/1/12 9:27
 * Dest  商品分类
 */
public class ClassifyGridViewAdapter extends ComAdapter<ChildrenBean> {

    private TextView mTvname;
    private ImageView mImageView;

    public ClassifyGridViewAdapter(Context context, List<ChildrenBean> childrenBeans) {
        super(context,childrenBeans,R.layout.item_classify);

    }

    @Override
    public void convert(ViewHolder holder, final ChildrenBean childrenBean, int position) {
        mImageView = holder.getItemView(R.id.iv_item_classify);
        mTvname = holder.getItemView(R.id.tv_name_item_classify);
        UIUtils.loadImageView(mContext,childrenBean.getImg(),mImageView);
        mTvname.setText(childrenBean.getName()+"");
        holder.getmConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClassifyGoodsListActivity.startActivity(mContext,childrenBean.getId()+"","");
            }
        });

    }
}
